package com.ruoyi.web.controller.his;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.HisEngineRuleCommon;
import com.ruoyi.system.service.IHisEngineRuleCommonService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 通用规则逻辑Controller
 * 
 * @author Alan
 * @date 2024-03-07
 */
@RestController
@RequestMapping("/system/common")
public class HisEngineRuleCommonController extends BaseController
{
    @Autowired
    private IHisEngineRuleCommonService hisEngineRuleCommonService;

    /**
     * 查询通用规则逻辑列表
     */
//    @PreAuthorize("@ss.hasPermi('system:common:list')")
    @GetMapping("/list")
    public TableDataInfo list(HisEngineRuleCommon hisEngineRuleCommon)
    {
        startPage();
        List<HisEngineRuleCommon> list = hisEngineRuleCommonService.selectHisEngineRuleCommonList(hisEngineRuleCommon);
        return getDataTable(list);
    }

    /**
     * 导出通用规则逻辑列表
     */
//    @PreAuthorize("@ss.hasPermi('system:common:export')")
    @Log(title = "通用规则逻辑", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(HisEngineRuleCommon hisEngineRuleCommon)
    {
        List<HisEngineRuleCommon> list = hisEngineRuleCommonService.selectHisEngineRuleCommonList(hisEngineRuleCommon);
        ExcelUtil<HisEngineRuleCommon> util = new ExcelUtil<HisEngineRuleCommon>(HisEngineRuleCommon.class);
        return util.exportExcel(list, "通用规则逻辑数据");
    }

    /**
     * 获取通用规则逻辑详细信息
     */
//    @PreAuthorize("@ss.hasPermi('system:common:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(hisEngineRuleCommonService.selectHisEngineRuleCommonById(id));
    }

    /**
     * 新增通用规则逻辑
     */
//    @PreAuthorize("@ss.hasPermi('system:common:add')")
    @Log(title = "通用规则逻辑", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HisEngineRuleCommon hisEngineRuleCommon)
    {
        return toAjax(hisEngineRuleCommonService.insertHisEngineRuleCommon(hisEngineRuleCommon));
    }

    /**
     * 修改通用规则逻辑
     */
//    @PreAuthorize("@ss.hasPermi('system:common:edit')")
    @Log(title = "通用规则逻辑", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HisEngineRuleCommon hisEngineRuleCommon)
    {
        return toAjax(hisEngineRuleCommonService.updateHisEngineRuleCommon(hisEngineRuleCommon));
    }

    /**
     * 删除通用规则逻辑
     */
//    @PreAuthorize("@ss.hasPermi('system:common:remove')")
    @Log(title = "通用规则逻辑", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(hisEngineRuleCommonService.deleteHisEngineRuleCommonByIds(ids));
    }
}
